package com.cloud.server.user.helper;

import com.cloud.core.db.entity.UserInfoEntity;
import com.cloud.core.param.server.req.UserReq;
import com.cloud.server.user.service.LoginTypeEnum;

/**
 * Created by cloudy.xie on 18/2/9.
 */
public abstract class UserHelper {
    public static UserInfoEntity userParamToEntity(UserReq userReq){
        UserInfoEntity entity = new UserInfoEntity();
        LoginTypeEnum loginTypeEnum = LoginTypeEnum.valueOf(userReq.getLoginType());
        switch (loginTypeEnum){
            case WEIXIN : entity.setOpenId(userReq.getAccount())  ;break;
            case WEIBO :  entity.setWeiboId(userReq.getAccount()); break;
            default:
                entity.setMobileNo(userReq.getAccount());
                entity.setPassword(userReq.getPassword());
        }

        entity.setAvata(userReq.getAvata());
        entity.setNickName(userReq.getNickName());

        return entity;
    }
}
